<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s"%>


<html>

<s:include value="header.jsp" />


<body>
	<div id="container">

		<div id="header">
			<a href="http://opencities.upf.edu"><img src="images/logo.png"></a>
			<h1>Data Sets</h1>
		</div>

		<s:include value="menu.jsp" />

		<div id="content" align="center">

			<%
				int val = 0;
			%>
			<div id="groupSearch">
				<table>
					<s:iterator value="groupList" >
						<%
							if (val == 0) {
									out.println("<tr>");
								}
						%>

						<td><a><img src="images/bubbles/bubble.png" width="32px" /></a>
						</td>
						
						<td><s:url action="serviceList" var="gaction">
						
								<s:param name="selectedGroup">
									<s:property />
								</s:param>
								
							
							</s:url> <a href="${gaction}" > <s:property /> 
						</a> </td>
						<%
							if (val == 4) {
									out.println("</tr>");
									val = 4;
								}
						%>
						<%
							val++;
								if (val == 5)
									val = 0;
						%>
					</s:iterator>
					<%
						if (val != 4)
							out.println("</tr>");
					%>
				</table>
			</div>

			<div id="bottom"> <br></div>
	
			<div id="searchBox" style="height: 20px">
				<s:form label="Search Services" action="searchServices"
					theme="simple">

					<s:text name="Search by tag:"></s:text>
					<s:textfield label="tag" name="selectBoxArgument" />
					<s:submit type="button" value="Search" />

				</s:form>
			</div>
			
			<div id="bottom"></div>

			<s:if test="%{searchResultsNum==0}">
				<!-- 				<table style="height: 200px"> -->

				<!-- 				</table> -->
				<br>
				<br>
<!-- 				<h2>No data set available for this category</h2> -->
			</s:if>
			<s:else>
				<div id="box-table-a" align="center" style="margin-left: 35px">
					<div style="overflow: auto;">

						<table>
							<tr>
								<th width="300x">Name</th>
								<th>Description</th>
								<th width="60px">Edit</th>
								<th width="60px">Delete</th>
							</tr>

							<s:iterator value="serviceList">
								<tr>
									<td width="250px"><s:url id="raction" action="getService">
											<s:param name="id" value='%{id}'></s:param>
											<s:param name="user" value='%{twitterAccount}'></s:param>
											<s:param name="lat" value='%{latitude}'></s:param>
											<s:param name="lon" value='%{longitude}'></s:param>
										</s:url> <s:a href="%{raction}">
											<b><s:property value='name' /></b>
										</s:a></td>
									<td width="450px"><s:property value='description' /></td>


									<s:if test="#session.user.email == email">
										<td width="60px" align="center"><s:url id="raction"
												action="editService">
												<s:param name="id" value='%{id}'></s:param>
											</s:url> <s:a href="%{raction}">
												<img src="images/edit.png">
											</s:a></td>

										<td width="60px" align="center"><s:url id="raction"
												action="deleteService">
												<s:param name="id" value='%{id}'></s:param>
											</s:url> <s:a href="%{raction}"
												onclick="return confirm('Are you sure you want to delete?')">
												<img src="images/trash.png">
											</s:a></td>
									</s:if>
									<s:else>
										<td width="60px" align="center"></td>
										<td width="60px" align="center"></td>
									</s:else>
								</tr>
							</s:iterator>

						</table>
					</div>
				</div>
			</s:else>
		</div>
		<s:include value="footer.jsp" />
	</div>
</body>

</html>
